
// 验证
var btn=document.querySelector(".btn")
var userName = document.querySelector(".user_name")
var userEmail = document.querySelector(".user_email")
var userTel = document.querySelector(".user_tel")
var textarea = document.querySelector(".textarea")
var tishi1 =document.querySelector(".tishi1")
var tishi2 =document.querySelector(".tishi2")
var tishi3 =document.querySelector(".tishi3")
var push=document.querySelector(".push")
var push1=document.querySelector('.push_1')
var pushC=document.querySelector(".push_cha")
var body = document.querySelector('body')
btn.addEventListener("click",function(){
    var str = userName.value.replace(/(^\s*)|(\s*$)/g, '');
    var str1 = textarea.value.replace(/(^\s*)|(\s*$)/g, '');
    if(str==''){
        tishi1.style.display="block";
    }else if(str1==""){
        tishi2.style.display="block";
        tishi1.style.display="none";
    }else{
        tishi2.style.display="none";
        tishi1.style.display="none";
        tishi3.style.display="block";
        push.style.display='block';
        body.style.overflow='hidden';
        ress()
        pushC.onclick=function(){
            push.style.display='none';
            body.style.overflow='visible';
        }

        setTimeout(function(){
            tishi3.style.display="none";
            push.style.display='none';
            body.style.overflow='visible';
            location.reload()
        },400000)
    }
});
// 拖拽
push1.onmousedown=function(ev){
    ev = ev || event
    var x =  ev.pageX - push1.offsetLeft
    var y =  ev.pageY - push1.offsetTop

    document.onmousemove = function(ev){
        ev=ev || event
        push1.style.left = ev.pageX - x + 'px';
        push1.style.top = ev.pageY - y + 'px';
    }
    document.onmouseup = function () {
        document.onmousemove= document.onmouseup = null;
    }

};

// 获取焦点时边框变色
userName.onfocus=function(){
    userName.style.borderColor='rgb(151, 229, 255)'
    userName.style.borderWidth='2PX'
}
userName.onblur=function(){
    userName.style.borderColor='#dadada'
    userName.style.borderWidth='1PX'
}
userEmail.onfocus=function(){
    userEmail.style.borderColor='rgb(151, 229, 255)'
    userEmail.style.borderWidth='2PX'
}
userEmail.onblur=function(){
    userEmail.style.borderColor='#dadada'
    userEmail.style.borderWidth='1PX'
}
userTel.onfocus=function(){
    userTel.style.borderColor='rgb(151, 229, 255)'
    userTel.style.borderWidth='2PX'
}
userTel.onblur=function(){
    userTel.style.borderColor='#dadada'
    userTel.style.borderWidth='1PX'
}

// 发送数据到后台
   
function ress(){
    ajax({
        type:"get",
        url:"http://localhost/aosuo/php/insert.php",
        data:{
            name:userName.value,
            emali:userEmail.value,
            tel:userTel.value,
            textarea:textarea.value,
        },
        success:function(res){
            console.log(res)               
        },
      
    })
} 

